home *** CD-ROM | disk | FTP | other *** search
- /* CleanPICT.h */
- /*
- * Common definitions for CleanPICT
- */
- #define NIL ((void *) 0)
- #include "OffscreenGrafPort.h"
- #define width(r) ((r).right - (r).left)
- #define height(r) ((r).bottom - (r).top)
-
- /*
- * MAGIC converts between the PICT bitmap (which is at
- * 300 dpi) and the screen at 72 dpi. This should be
- * determined by examining the actual input file so
- * we can handle 72 dpi PICT's too.
- *
- * Note: this is specific to the actual picture -- for
- * some pictures, you don't want this. If you are
- * trying to clean a picture and nothing seems to be
- * happening, you might try either changing MAGIC to one
- * or try multiplying the threshold by four.
- */
- #define MAGIC 4
- /*
- * XMAX and YMAX dimension the bit-array that marks
- * the island. These values should be about twice
- * the size of the largest expected threshold.
- * In any case (XMAX * YMAX) must not exceed 32767.
- * By making XMAX and YMAX powers of two, we can
- * replace multiplies by shifts for a significant
- * speed-up. If max is too high, the program will
- * run slower (due to the time needed to empty the
- * seen map); if too small, some long thin islands
- * won't be removed.
- */
- #define LOG_XMAX 5
- #define LOG_YMAX 5
- #define XMAX (1 << LOG_XMAX) /* Maximum pixels */
- #define YMAX (1 << LOG_YMAX) /* Maximum pixels */
- #define THRESHOLD 8 /* Default threshold */
-
- typedef unsigned long Ulong;
-
- /*
- * State controls the interaction between the
- * pixel cleaner and the event loop.
- */
- enum State {
- Idle = 0, /* Must be zero */
- Init, /* Initialize a new cleaning */
- Working /* Cleaning is in progress */
- };
-
- /*
- * All the information about a document is stored here.
- * Note that, when the toolbox selects a window, we can
- * immediately recover the document. This lets us work
- * on multiple documents, which is probably useless
- * even though it's easy to do.
- */
- typedef struct {
- WindowRecord window; /* Watch process here */
- GrafPtr pictPort; /* The PICT itself */
- Rect pictSize; /* The picture's bounds */
- enum State state; /* What's up, DOC? */
- short threshold; /* Island threshold */
- Boolean dirty; /* TRUE if need write */
- Str255 fileName; /* PICT's file name */
- /*
- * The count variable is incremented whenever an island
- * point is seen. If it exceeds threshold, this is
- * not an erasable island.
- */
- short count;
- /*
- * The center variable defines the point currently
- * being examined as a potential island. This variable
- * is in the DOC.pictPort coordinate space.
- */
- Point center;
- /*
- * These two values define the bottom of the PICT:
- * we don't look at the last row or column. These
- * probably should be Ulong's
- */
- short bottom;
- short right;
- /*
- * The island variable defines the "color" we're looking
- * for: this needs some work to handle color PICT's.
- */
- Boolean island;
- /*
- * The updateRect tracks the pixels that need to be
- * changed on screen. updateCount is used to determine
- * when to force an update.
- */
- RgnHandle thisUpdateRgn; /* The current island */
- RgnHandle updateRgn; /* This needs updating */
- short updateCount; /* When this overflows */
- /*
- * Here are some statistics for user-friendlyness.
- */
- Ulong examined; /* Points closely watched */
- Ulong found; /* Islands erased */
- Ulong start; /* When cleaning started */
- Ulong elapsed; /* Elapsed seconds */
- Ulong elapsed_shown; /* On about window */
- } DocumentRecord, *DocumentPtr;
-
- /*
- * The current window is always stored in a local
- * WindowPtr variable named "window." If it's ours,
- * we can access the document by casting window to
- * DocumentPtr and de-referencing it.
- */
- #define DOC (*((DocumentPtr) window))
-
- void clean_picture(WindowPtr, Boolean);
- OSErr read_picture(WindowPtr, int);
- void update_picture(WindowPtr);
- void write_picture(WindowPtr, int);
- void make_about_window(WindowPtr);
-
- #define pstrcpy(out, in) \
- BlockMove((in), (out), ((unsigned char *)(in))[0] + 1)
- void pstrcat(void *, void *);
- #define WATCH_CURSOR SetCursor(*GetCursor(watchCursor))
- #define ARROW_CURSOR SetCursor(&arrow)
-
-